
//
//  GWEmotionView.m
//  新浪微博
//
//  Created by qianfeng on 16/2/21.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWEmotionView.h"
#import "GWEmotion.h"
@implementation GWEmotionView


-(instancetype)initWithFrame:(CGRect)frame
{
    if (self =[super initWithFrame:frame]) {
        self.adjustsImageWhenHighlighted =NO;
    }
    return self;
}

-(void)setEmotion:(GWEmotion *)emotion
{
    _emotion =emotion;
    
    if (emotion.emoji) {
        [UIView setAnimationsEnabled:NO];
        [self setTitle:emotion.emoji forState:UIControlStateNormal];
        self.titleLabel.font =[UIFont systemFontOfSize:32];
        [self setImage:nil forState:UIControlStateNormal];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [UIView setAnimationsEnabled:YES];
        });
    }
    else
    {
        NSString *path =[NSString stringWithFormat:@"%@/%@",emotion.filePath,emotion.png];
        [self setImage:[[UIImage imageNamed:path] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        [self setTitle:nil forState:UIControlStateNormal];
    }
}
@end
